package org.ibase4j.thired;

import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.ibase4j.system.model.SysUser;
import org.ibase4j.system.service.SysUserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import top.ibase4j.core.base.BaseController;

import java.util.Map;

/**
 * 菜单管理
 * 
 * @author ShenHuaJie
 * @version 2016年5月20日 下午3:14:54
 */
@Controller
@RequestMapping(value = "syspage/user")
public class PageUserController extends BaseController<SysUser, SysUserService> {
    private String prefix = "system/user";

    @GetMapping("/view")
    public String view()
    {
        return prefix + "/user";
    }

    @ApiOperation(value = "查询菜单")
    @GetMapping(value = "/list")
    @RequiresPermissions("model.base.user.read")
    @ResponseBody
    public Object query(ModelMap modelMap, @RequestParam Map<String, Object> param) {
//        Map<String, Object> param = new HashMap<>();
        return super.query(modelMap, param);
    }

    /**
     * 选择菜单图标
     */
    @GetMapping("/icon")
    public String icon()
    {
        return prefix + "/icon";
    }

    /**
     * 新增
     */
    @GetMapping("/add")
    public String add(ModelMap mmap)
    {
        return prefix + "/add";
    }

    /**
     * 修改菜单
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SysUser result = service.queryById(id);
        result.setPassword(null);
        mmap.put("user", result);
        return prefix + "/edit";
    }

}
